package com.hs.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import com.hs.entity.dto.TeamType;

import com.hs.mapper.TeamTypeMapper;

import com.hs.service.TeamTypeService;
import jakarta.annotation.Resource;
import org.apache.ibatis.logging.Log;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class TeamTypeServiceImpl extends ServiceImpl<TeamTypeMapper, TeamType> implements TeamTypeService {


    @Resource
    private TeamTypeMapper TeamTypeMapper;



    @Override
    public PageInfo<TeamType> selectTeamTypeList(Integer pageNum, String keywords) {
        PageHelper.startPage(pageNum,5);

        QueryWrapper<TeamType> queryWrapper = new QueryWrapper<>();

        if (keywords != null && !keywords.isEmpty()) {
            queryWrapper.like("team_type_name", keywords);  // 根据用户名进行模糊查询
        }

        List<TeamType> teamList = TeamTypeMapper.selectListWithTeamName(queryWrapper);
        return new PageInfo<>(teamList);
    }

    @Override
    public List<TeamType> getAllTeamTypeList() {
        return TeamTypeMapper.selectListWithTeamName(null);
    }
}
